scale_x_continuous(breaks=c(0, 2.91, 5.76, 8.61, 11.46, 14.31, 17.16, 20.01, 22.75),
labels = c("0\n(Min.)", "2.91\n(μ-2SD)", "5.76\n(μ-1SD)", "8.61\n(μ)", "11.46\n(μ+1SD)", "14.31\n(μ+2SD)", "17.16\n(μ+3SD)", "20.01\n(μ+4SD)", "22.75\n(Max.)")) + scale_y_continuous(breaks=number_ticks(10)) +
labs(    x = "\n Sleep Duration (in Hours)\n",
y = "\n Fitted Values of Turnout \n",
title = "")
finland_plot
finland_plot <- ggplot(finland, aes(x=sleep_duration, y=predicted_finland)) +
geom_point()  +
stat_smooth(method='lm', formula = y ~ x, size = 0.5, level = 0.95, fullrange = TRUE, color = "black", linetype="longdash") +
stat_smooth(method='lm', formula = y ~ poly(x,2), size = 0.5, level = 0.95, fullrange = TRUE, color = "black") +
theme_classic() + ggpubr::grids(linetype = "dashed") +
theme(axis.text.x=element_text(colour="black", size = 12), axis.text.y=element_text(colour="black", size = 12)) +
theme(axis.title=element_text(size=14, colour="black", face="bold"), legend.text=element_text(size=14), legend.title=element_text(size=14)) +
scale_x_continuous(breaks=c(0, 2.91, 5.76, 8.61, 11.46, 14.31, 17.16, 20.01, 22.75),
labels = c("0\n(Min.)", "2.91\n(μ-2SD)", "5.76\n(μ-1SD)", "8.61\n(μ)", "11.46\n(μ+1SD)", "14.31\n(μ+2SD)", "17.16\n(μ+3SD)", "20.01\n(μ+4SD)", "22.75\n(Max.)")) + scale_y_continuous(breaks=number_ticks(10)) +
scale_y_continuous(labels = function(x) paste0(x * 100, '%'), limits = c(0.70, 0.90), breaks = seq(0.70,0.90, by = .05)) +
labs(    x = "\n Sleep Duration (in Hours)\n",
y = "\n Fitted Values of Turnout \n",
title = "")
finland_plot
finland_plot <- ggExtra::ggMarginal(finland_plot, type = "boxplot")
finland_plot
issp_2007$predicted_greece <- predict(poly.issp.m1,
newdata=transform(issp_2007,
urban_rural_area_beta = 0,
age_beta  = 0,
degree_beta  = 0,
income_beta   = 0,
sex_beta   = 0,
political_interest_beta   = 0,
religiosity_beta = 0,
country="Greece",
local_election=0,
mid_field_season=0,
day_off=0), type = "response", allow.new.levels=T)
greece <- subset(issp_2007, subset = country == "Greece", select = c("sleep_duration", "predicted_greece"))
describe(greece$predicted_greece)
table(greece$predicted_greece)
describe(greece$sleep_duration)
greece_plot <- ggplot(greece, aes(x=sleep_duration, y=predicted_greece)) +
geom_point()  +
stat_smooth(method='lm', formula = y ~ x, size = 0.5, level = 0.95, fullrange = TRUE, color = "black", linetype="longdash") +
stat_smooth(method='lm', formula = y ~ poly(x,2), size = 0.5, level = 0.95, fullrange = TRUE, color = "black") +
theme_classic() + ggpubr::grids(linetype = "dashed") +
theme(axis.text.x=element_text(colour="black", size = 12), axis.text.y=element_text(colour="black", size = 12)) +
theme(axis.title=element_text(size=14, colour="black", face="bold"), legend.text=element_text(size=14), legend.title=element_text(size=14)) +
scale_x_continuous(breaks=c(0, 2.23, 5.1, 7.9, 10.7, 13.5, 16.3, 20),
labels = c("0\n(Min.)", "2.26\n(μ-4SD)", "5.1\n(μ-2SD)",  "7.9\n(μ)",  "10.7\n(μ+2SD)",  "13.5\n(μ+4SD)", "16.3\n(μ+6SD)", "20\n(Max.)")) + scale_y_continuous(breaks=number_ticks(10)) +
labs(    x = "\n Sleep Duration (in Hours)\n",
y = "\n Fitted Values of Turnout \n",
title = "")
greece_plot
greece_plot <- ggplot(greece, aes(x=sleep_duration, y=predicted_greece)) +
geom_point()  +
stat_smooth(method='lm', formula = y ~ x, size = 0.5, level = 0.95, fullrange = TRUE, color = "black", linetype="longdash") +
stat_smooth(method='lm', formula = y ~ poly(x,2), size = 0.5, level = 0.95, fullrange = TRUE, color = "black") +
theme_classic() + ggpubr::grids(linetype = "dashed") +
theme(axis.text.x=element_text(colour="black", size = 12), axis.text.y=element_text(colour="black", size = 12)) +
theme(axis.title=element_text(size=14, colour="black", face="bold"), legend.text=element_text(size=14), legend.title=element_text(size=14)) +
scale_x_continuous(breaks=c(0, 2.23, 5.1, 7.9, 10.7, 13.5, 16.3, 20),
labels = c("0\n(Min.)", "2.26\n(μ-4SD)", "5.1\n(μ-2SD)",  "7.9\n(μ)",  "10.7\n(μ+2SD)",  "13.5\n(μ+4SD)", "16.3\n(μ+6SD)", "20\n(Max.)")) + scale_y_continuous(breaks=number_ticks(10)) +
scale_y_continuous(labels = function(x) paste0(x * 100, '%'), limits = c(0.89, 0.92), breaks = seq(0.89, 0.92, by = .01)) +
labs(    x = "\n Sleep Duration (in Hours)\n",
y = "\n Fitted Values of Turnout \n",
title = "")
greece_plot
greece_plot <- ggExtra::ggMarginal(greece_plot, type = "boxplot")
greece_plot
greece_plot <- ggplot(greece, aes(x=sleep_duration, y=predicted_greece)) +
geom_point()  +
stat_smooth(method='lm', formula = y ~ x, size = 0.5, level = 0.95, fullrange = TRUE, color = "black", linetype="longdash") +
stat_smooth(method='lm', formula = y ~ poly(x,2), size = 0.5, level = 0.95, fullrange = TRUE, color = "black") +
theme_classic() + ggpubr::grids(linetype = "dashed") +
theme(axis.text.x=element_text(colour="black", size = 12), axis.text.y=element_text(colour="black", size = 12)) +
theme(axis.title=element_text(size=14, colour="black", face="bold"), legend.text=element_text(size=14), legend.title=element_text(size=14)) +
scale_x_continuous(breaks=c(0, 2.23, 5.1, 7.9, 10.7, 13.5, 16.3, 20),
labels = c("0\n(Min.)", "2.26\n(μ-4SD)", "5.1\n(μ-2SD)",  "7.9\n(μ)",  "10.7\n(μ+2SD)",  "13.5\n(μ+4SD)", "16.3\n(μ+6SD)", "20\n(Max.)")) + scale_y_continuous(breaks=number_ticks(10)) +
scale_y_continuous(labels = function(x) paste0(x * 100, '%'), limits = c(0.89, 0.92), breaks = seq(0.89, 0.92, by = .005)) +
labs(    x = "\n Sleep Duration (in Hours)\n",
y = "\n Fitted Values of Turnout \n",
title = "")
greece_plot
greece_plot <- ggExtra::ggMarginal(greece_plot, type = "boxplot")
greece_plot
issp_2007$predicted_ireland <- predict(poly.issp.m1,
newdata=transform(issp_2007,
urban_rural_area_beta = 0,
age_beta  = 0,
degree_beta  = 0,
income_beta   = 0,
sex_beta   = 0,
political_interest_beta   = 0,
religiosity_beta = 0,
country="Ireland",
local_election=0,
mid_field_season=0,
day_off=0), type = "response", allow.new.levels=T)
ireland <- subset(issp_2007, subset = country == "Ireland", select = c("sleep_duration", "predicted_ireland"))
describe(ireland$predicted_ireland)
table(ireland$predicted_ireland)
describe(ireland$sleep_duration)
ireland_plot <- ggplot(ireland, aes(x=sleep_duration, y=predicted_ireland)) +
geom_point()  +
stat_smooth(method='lm', formula = y ~ x, size = 0.5, level = 0.95, fullrange = TRUE, color = "black", linetype="longdash") +
stat_smooth(method='lm', formula = y ~ poly(x,2), size = 0.5, level = 0.95, fullrange = TRUE, color = "black") +
theme_classic() + ggpubr::grids(linetype = "dashed") +
theme(axis.text.x=element_text(colour="black", size = 12), axis.text.y=element_text(colour="black", size = 12)) +
theme(axis.title=element_text(size=14, colour="black", face="bold"), legend.text=element_text(size=14), legend.title=element_text(size=14)) +
scale_x_continuous(breaks=c(2, 3.78, 6.25, 8.72, 11.19, 13.66, 16.13, 18.6, 21.07, 22.92),
labels = c("2\n(Min.)", "3.78\n(μ-2SD)", "6.25\n(μ-1SD)", "8.72\n(μ)", "11.19\n(μ+1SD)", "13.66\n(μ+2SD)", "16.13\n(μ+3SD)", "18.6\n(μ+4SD)", "21.07\n(μ+5SD)", "22.92\n(Max.)")) + scale_y_continuous(breaks=number_ticks(10)) +
labs(    x = "\n Sleep Duration (in Hours)\n",
y = "\n Fitted Values of Turnout \n",
title = "")
ireland_plot
ireland_plot <- ggplot(ireland, aes(x=sleep_duration, y=predicted_ireland)) +
geom_point()  +
stat_smooth(method='lm', formula = y ~ x, size = 0.5, level = 0.95, fullrange = TRUE, color = "black", linetype="longdash") +
stat_smooth(method='lm', formula = y ~ poly(x,2), size = 0.5, level = 0.95, fullrange = TRUE, color = "black") +
theme_classic() + ggpubr::grids(linetype = "dashed") +
theme(axis.text.x=element_text(colour="black", size = 12), axis.text.y=element_text(colour="black", size = 12)) +
theme(axis.title=element_text(size=14, colour="black", face="bold"), legend.text=element_text(size=14), legend.title=element_text(size=14)) +
scale_x_continuous(breaks=c(2, 3.78, 6.25, 8.72, 11.19, 13.66, 16.13, 18.6, 21.07, 22.92),
labels = c("2\n(Min.)", "3.78\n(μ-2SD)", "6.25\n(μ-1SD)", "8.72\n(μ)", "11.19\n(μ+1SD)", "13.66\n(μ+2SD)", "16.13\n(μ+3SD)", "18.6\n(μ+4SD)", "21.07\n(μ+5SD)", "22.92\n(Max.)")) + scale_y_continuous(breaks=number_ticks(10)) +
scale_y_continuous(labels = function(x) paste0(x * 100, '%'), limits = c(0.45, 0.90), breaks = seq(0.45, 0.90, by = .05)) +
labs(    x = "\n Sleep Duration (in Hours)\n",
y = "\n Fitted Values of Turnout \n",
title = "")
ireland_plot
ireland_plot <- ggExtra::ggMarginal(ireland_plot, type = "boxplot")
ireland_plot
issp_2007$predicted_mexico <- predict(poly.issp.m1,
newdata=transform(issp_2007,
urban_rural_area_beta = 0,
age_beta  = 0,
degree_beta  = 0,
income_beta   = 0,
sex_beta   = 0,
political_interest_beta   = 0,
religiosity_beta = 0,
country="Mexico",
local_election=0,
mid_field_season=0,
day_off=0), type = "response", allow.new.levels=T)
mexico <- subset(issp_2007, subset = country == "Mexico", select = c("sleep_duration", "predicted_mexico"))
describe(mexico$predicted_mexico)
table(mexico$predicted_mexico)
describe(mexico$sleep_duration)
mexico_plot <- ggplot(mexico, aes(x=sleep_duration, y=predicted_mexico)) +
geom_point()  +
stat_smooth(method='lm', formula = y ~ x, size = 0.5, level = 0.95, fullrange = TRUE, color = "black", linetype="longdash") +
stat_smooth(method='lm', formula = y ~ poly(x,2), size = 0.5, level = 0.95, fullrange = TRUE, color = "black") +
theme_classic() + ggpubr::grids(linetype = "dashed") +
theme(axis.text.x=element_text(colour="black", size = 12), axis.text.y=element_text(colour="black", size = 12)) +
theme(axis.title=element_text(size=14, colour="black", face="bold"), legend.text=element_text(size=14), legend.title=element_text(size=14)) +
scale_x_continuous(breaks=c(1, 2.13, 4.1, 6.07, 8.04, 10.01, 11.98, 13.95, 15.92, 17.89, 20.17),
labels = c("1\n(Min.)", "2.13\n(μ-3SD)", "4.1\n(μ-2SD)", "6.07\n(μ-1SD)", "8.04\n(μ)", "10.01\n(μ+1SD)", "11.95\n(μ+2SD)", "13.97\n(μ+3SD)", "15.92\n(μ+4SD)", "17.89\n(μ+5SD)", "20.17\n(Max.)")) + scale_y_continuous(breaks=number_ticks(10)) +
scale_y_continuous(labels = function(x) paste0(x * 100, '%'), limits = c(0.55, 0.9), breaks = seq(0.55,0.9, by = .05)) +
labs(    x = "\n Sleep Duration (in Hours)\n",
y = "\n Fitted Values of Turnout \n",
title = "")
mexico_plot <- ggplot(mexico, aes(x=sleep_duration, y=predicted_mexico)) +
geom_point()  +
stat_smooth(method='lm', formula = y ~ x, size = 0.5, level = 0.95, fullrange = TRUE, color = "black", linetype="longdash") +
stat_smooth(method='lm', formula = y ~ poly(x,2), size = 0.5, level = 0.95, fullrange = TRUE, color = "black") +
theme_classic() + ggpubr::grids(linetype = "dashed") +
theme(axis.text.x=element_text(colour="black", size = 12), axis.text.y=element_text(colour="black", size = 12)) +
theme(axis.title=element_text(size=14, colour="black", face="bold"), legend.text=element_text(size=14), legend.title=element_text(size=14)) +
scale_x_continuous(breaks=c(1, 2.13, 4.1, 6.07, 8.04, 10.01, 11.98, 13.95, 15.92, 17.89, 20.17),
labels = c("1\n(Min.)", "2.13\n(μ-3SD)", "4.1\n(μ-2SD)", "6.07\n(μ-1SD)", "8.04\n(μ)", "10.01\n(μ+1SD)", "11.95\n(μ+2SD)", "13.97\n(μ+3SD)", "15.92\n(μ+4SD)", "17.89\n(μ+5SD)", "20.17\n(Max.)")) + scale_y_continuous(breaks=number_ticks(10)) +
labs(    x = "\n Sleep Duration (in Hours)\n",
y = "\n Fitted Values of Turnout \n",
title = "")
mexico_plot
mexico_plot <- ggplot(mexico, aes(x=sleep_duration, y=predicted_mexico)) +
geom_point()  +
stat_smooth(method='lm', formula = y ~ x, size = 0.5, level = 0.95, fullrange = TRUE, color = "black", linetype="longdash") +
stat_smooth(method='lm', formula = y ~ poly(x,2), size = 0.5, level = 0.95, fullrange = TRUE, color = "black") +
theme_classic() + ggpubr::grids(linetype = "dashed") +
theme(axis.text.x=element_text(colour="black", size = 12), axis.text.y=element_text(colour="black", size = 12)) +
theme(axis.title=element_text(size=14, colour="black", face="bold"), legend.text=element_text(size=14), legend.title=element_text(size=14)) +
scale_x_continuous(breaks=c(1, 2.13, 4.1, 6.07, 8.04, 10.01, 11.98, 13.95, 15.92, 17.89, 20.17),
labels = c("1\n(Min.)", "2.13\n(μ-3SD)", "4.1\n(μ-2SD)", "6.07\n(μ-1SD)", "8.04\n(μ)", "10.01\n(μ+1SD)", "11.95\n(μ+2SD)", "13.97\n(μ+3SD)", "15.92\n(μ+4SD)", "17.89\n(μ+5SD)", "20.17\n(Max.)")) + scale_y_continuous(breaks=number_ticks(10)) +
scale_y_continuous(labels = function(x) paste0(x * 100, '%'), limits = c(0.60, 0.9), breaks = seq(0.60,0.9, by = .05)) +
labs(    x = "\n Sleep Duration (in Hours)\n",
y = "\n Fitted Values of Turnout \n",
title = "")
mexico_plot
mexico_plot <- ggExtra::ggMarginal(mexico_plot, type = "boxplot")
mexico_plot
issp_2007$predicted_new_zealand <- predict(poly.issp.m1,
newdata=transform(issp_2007,
urban_rural_area_beta = 0,
age_beta  = 0,
degree_beta  = 0,
income_beta   = 0,
sex_beta   = 0,
political_interest_beta   = 0,
religiosity_beta = 0,
country="New Zealand",
local_election=0,
mid_field_season=0,
day_off=0), type = "response", allow.new.levels=T)
new_zealand <- subset(issp_2007, subset = country == "New Zealand", select = c("sleep_duration", "predicted_new_zealand"))
describe(new_zealand$predicted_new_zealand)
table(new_zealand$predicted_new_zealand)
describe(new_zealand$sleep_duration)
new_zealand_plot <- ggplot(new_zealand, aes(x=sleep_duration, y=predicted_new_zealand)) +
geom_point()  +
stat_smooth(method='lm', formula = y ~ x, size = 0.5, level = 0.95, fullrange = TRUE, color = "black", linetype="longdash") +
stat_smooth(method='lm', formula = y ~ poly(x,2), size = 0.5, level = 0.95, fullrange = TRUE, color = "black") +
theme_classic() + ggpubr::grids(linetype = "dashed") +
theme(axis.text.x=element_text(colour="black", size = 12), axis.text.y=element_text(colour="black", size = 12)) +
theme(axis.title=element_text(size=14, colour="black", face="bold"), legend.text=element_text(size=14), legend.title=element_text(size=14)) +
scale_x_continuous(breaks=c(0.72, 3.03, 6.79, 8.67, 10.55, 14.31, 18.07, 22.5),
labels = c("0.72\n(Min.)", "3.03\n(μ-3SD)",  "6.79\n(μ-1SD)", "8.67\n(μ)", "10.55\n(μ+1SD)",  "14.31\n(μ+3SD)", "18.07\n(μ+5SD)" ,  "22.5\n(Max.)")) + scale_y_continuous(breaks=number_ticks(10)) +
labs(    x = "\n Sleep Duration (in Hours)\n",
y = "\n Fitted Values of Turnout \n",
title = "")
new_zealand_plot
new_zealand_plot <- ggplot(new_zealand, aes(x=sleep_duration, y=predicted_new_zealand)) +
geom_point()  +
stat_smooth(method='lm', formula = y ~ x, size = 0.5, level = 0.95, fullrange = TRUE, color = "black", linetype="longdash") +
stat_smooth(method='lm', formula = y ~ poly(x,2), size = 0.5, level = 0.95, fullrange = TRUE, color = "black") +
theme_classic() + ggpubr::grids(linetype = "dashed") +
theme(axis.text.x=element_text(colour="black", size = 12), axis.text.y=element_text(colour="black", size = 12)) +
theme(axis.title=element_text(size=14, colour="black", face="bold"), legend.text=element_text(size=14), legend.title=element_text(size=14)) +
scale_x_continuous(breaks=c(0.72, 3.03, 6.79, 8.67, 10.55, 14.31, 18.07, 22.5),
labels = c("0.72\n(Min.)", "3.03\n(μ-3SD)",  "6.79\n(μ-1SD)", "8.67\n(μ)", "10.55\n(μ+1SD)",  "14.31\n(μ+3SD)", "18.07\n(μ+5SD)" ,  "22.5\n(Max.)")) + scale_y_continuous(breaks=number_ticks(10)) +
scale_y_continuous(labels = function(x) paste0(x * 100, '%'), limits = c(0.88, 0.93), breaks = seq(0.88, 0.93, by = 0.01)) +
labs(    x = "\n Sleep Duration (in Hours)\n",
y = "\n Fitted Values of Turnout \n",
title = "")
new_zealand_plot
new_zealand_plot <- ggplot(new_zealand, aes(x=sleep_duration, y=predicted_new_zealand)) +
geom_point()  +
stat_smooth(method='lm', formula = y ~ x, size = 0.5, level = 0.95, fullrange = TRUE, color = "black", linetype="longdash") +
stat_smooth(method='lm', formula = y ~ poly(x,2), size = 0.5, level = 0.95, fullrange = TRUE, color = "black") +
theme_classic() + ggpubr::grids(linetype = "dashed") +
theme(axis.text.x=element_text(colour="black", size = 12), axis.text.y=element_text(colour="black", size = 12)) +
theme(axis.title=element_text(size=14, colour="black", face="bold"), legend.text=element_text(size=14), legend.title=element_text(size=14)) +
scale_x_continuous(breaks=c(0.72, 3.03, 6.79, 8.67, 10.55, 14.31, 18.07, 22.5),
labels = c("0.72\n(Min.)", "3.03\n(μ-3SD)",  "6.79\n(μ-1SD)", "8.67\n(μ)", "10.55\n(μ+1SD)",  "14.31\n(μ+3SD)", "18.07\n(μ+5SD)" ,  "22.5\n(Max.)")) + scale_y_continuous(breaks=number_ticks(10)) +
scale_y_continuous(labels = function(x) paste0(x * 100, '%'), limits = c(0.89, 0.93), breaks = seq(0.89, 0.93, by = 0.01)) +
labs(    x = "\n Sleep Duration (in Hours)\n",
y = "\n Fitted Values of Turnout \n",
title = "")
new_zealand_plot
new_zealand_plot <- ggExtra::ggMarginal(new_zealand_plot, type = "boxplot")
new_zealand_plot
issp_2007$predicted_philippines <- predict(poly.issp.m1,
newdata=transform(issp_2007,
urban_rural_area_beta = 0,
age_beta  = 0,
degree_beta  = 0,
income_beta   = 0,
sex_beta   = 0,
political_interest_beta   = 0,
religiosity_beta = 0,
country="the Philippines",
local_election=0,
mid_field_season=0,
day_off=0), type = "response", allow.new.levels=T)
philippines <- subset(issp_2007, subset = country == "the Philippines", select = c("sleep_duration", "predicted_philippines"))
describe(philippines$predicted_philippines)
table(philippines$predicted_philippines)
describe(philippines$sleep_duration)
philippines_plot <- ggplot(philippines, aes(x=sleep_duration, y=predicted_philippines)) +
geom_point()  +
stat_smooth(method='lm', formula = y ~ x, size = 0.5, level = 0.95, fullrange = TRUE, color = "black", linetype="longdash") +
stat_smooth(method='lm', formula = y ~ poly(x,2), size = 0.5, level = 0.95, fullrange = TRUE, color = "black") +
theme_classic() + ggpubr::grids(linetype = "dashed") +
theme(axis.text.x=element_text(colour="black", size = 12), axis.text.y=element_text(colour="black", size = 12)) +
theme(axis.title=element_text(size=14, colour="black", face="bold"), legend.text=element_text(size=14), legend.title=element_text(size=14)) +
scale_x_continuous(breaks=c(1, 3.6, 5.98, 8.36, 10.74, 13.12, 15.55, 17.88, 20.26 , 22),
labels = c("1\n(Min.)", "3.6\n(μ-2SD)", "5.98\n(μ-1SD)", "8.36\n(μ)", "10.74\n(μ+1SD)", "13.12\n(μ+2SD)",  "15.55\n(μ+3SD)",  "17.88\n(μ+4SD)",   "20.26\n(μ+5SD)",  "22\n(Max.)")) + scale_y_continuous(breaks=number_ticks(10)) +
labs(    x = "\n Sleep Duration (in Hours)\n",
y = "\n Fitted Values of Turnout \n",
title = "")
philippines_plot
philippines_plot <- ggplot(philippines, aes(x=sleep_duration, y=predicted_philippines)) +
geom_point()  +
stat_smooth(method='lm', formula = y ~ x, size = 0.5, level = 0.95, fullrange = TRUE, color = "black", linetype="longdash") +
stat_smooth(method='lm', formula = y ~ poly(x,2), size = 0.5, level = 0.95, fullrange = TRUE, color = "black") +
theme_classic() + ggpubr::grids(linetype = "dashed") +
theme(axis.text.x=element_text(colour="black", size = 12), axis.text.y=element_text(colour="black", size = 12)) +
theme(axis.title=element_text(size=14, colour="black", face="bold"), legend.text=element_text(size=14), legend.title=element_text(size=14)) +
scale_x_continuous(breaks=c(1, 3.6, 5.98, 8.36, 10.74, 13.12, 15.55, 17.88, 20.26 , 22),
labels = c("1\n(Min.)", "3.6\n(μ-2SD)", "5.98\n(μ-1SD)", "8.36\n(μ)", "10.74\n(μ+1SD)", "13.12\n(μ+2SD)",  "15.55\n(μ+3SD)",  "17.88\n(μ+4SD)",   "20.26\n(μ+5SD)",  "22\n(Max.)")) + scale_y_continuous(breaks=number_ticks(10)) +
scale_y_continuous(labels = function(x) paste0(x * 100, '%'), limits = c(0.67, 0.90), breaks = seq(0.67,0.90, by = .03)) +
labs(    x = "\n Sleep Duration (in Hours)\n",
y = "\n Fitted Values of Turnout \n",
title = "")
philippines_plot
philippines_plot <- ggplot(philippines, aes(x=sleep_duration, y=predicted_philippines)) +
geom_point()  +
stat_smooth(method='lm', formula = y ~ x, size = 0.5, level = 0.95, fullrange = TRUE, color = "black", linetype="longdash") +
stat_smooth(method='lm', formula = y ~ poly(x,2), size = 0.5, level = 0.95, fullrange = TRUE, color = "black") +
theme_classic() + ggpubr::grids(linetype = "dashed") +
theme(axis.text.x=element_text(colour="black", size = 12), axis.text.y=element_text(colour="black", size = 12)) +
theme(axis.title=element_text(size=14, colour="black", face="bold"), legend.text=element_text(size=14), legend.title=element_text(size=14)) +
scale_x_continuous(breaks=c(1, 3.6, 5.98, 8.36, 10.74, 13.12, 15.55, 17.88, 20.26 , 22),
labels = c("1\n(Min.)", "3.6\n(μ-2SD)", "5.98\n(μ-1SD)", "8.36\n(μ)", "10.74\n(μ+1SD)", "13.12\n(μ+2SD)",  "15.55\n(μ+3SD)",  "17.88\n(μ+4SD)",   "20.26\n(μ+5SD)",  "22\n(Max.)")) + scale_y_continuous(breaks=number_ticks(10)) +
scale_y_continuous(labels = function(x) paste0(x * 100, '%'), limits = c(0.67, 0.90), breaks = seq(0.67,0.91, by = .03)) +
labs(    x = "\n Sleep Duration (in Hours)\n",
y = "\n Fitted Values of Turnout \n",
title = "")
philippines_plot
philippines_plot <- ggExtra::ggMarginal(philippines_plot, type = "boxplot")
philippines_plot
issp_2007$predicted_south_korea <- predict(poly.issp.m1,
newdata=transform(issp_2007,
urban_rural_area_beta = 0,
age_beta  = 0,
degree_beta  = 0,
income_beta   = 0,
sex_beta   = 0,
political_interest_beta   = 0,
religiosity_beta = 0,
country="South Korea",
local_election=0,
mid_field_season=0,
day_off=0), type = "response", allow.new.levels=T)
south_korea <- subset(issp_2007, subset = country == "South Korea", select = c("sleep_duration", "predicted_south_korea"))
describe(south_korea$predicted_south_korea)
table(south_korea$predicted_south_korea)
describe(south_korea$sleep_duration)
south_korea_plot <- ggplot(south_korea, aes(x=sleep_duration, y=predicted_south_korea)) +
geom_point()  +
stat_smooth(method='lm', formula = y ~ x, size = 0.5, level = 0.95, fullrange = TRUE, color = "black", linetype="longdash") +
stat_smooth(method='lm', formula = y ~ poly(x,2), size = 0.5, level = 0.95, fullrange = TRUE, color = "black") +
theme_classic() + ggpubr::grids(linetype = "dashed") +
theme(axis.text.x=element_text(colour="black", size = 12), axis.text.y=element_text(colour="black", size = 12)) +
theme(axis.title=element_text(size=14, colour="black", face="bold"), legend.text=element_text(size=14), legend.title=element_text(size=14)) +
scale_x_continuous(breaks=c(0, 1.81, 4.54, 7.27, 10, 12.73, 15.46, 18.19, 22),
labels = c("0\n(Min.)", "1.81\n(μ-2SD)", "4.54\n(μ-1SD)", "7.27\n(μ)", "10\n(μ+1SD)", "12.73\n(μ+2SD)","15.46\n(μ+3SD)", "18.19\n(μ+4SD)",  "22\n(Max.)")) + scale_y_continuous(breaks=number_ticks(10)) +
labs(    x = "\n Sleep Duration (in Hours)\n",
y = "\n Fitted Values of Turnout \n",
title = "")
south_korea_plot
south_korea_plot <- ggplot(south_korea, aes(x=sleep_duration, y=predicted_south_korea)) +
geom_point()  +
stat_smooth(method='lm', formula = y ~ x, size = 0.5, level = 0.95, fullrange = TRUE, color = "black", linetype="longdash") +
stat_smooth(method='lm', formula = y ~ poly(x,2), size = 0.5, level = 0.95, fullrange = TRUE, color = "black") +
theme_classic() + ggpubr::grids(linetype = "dashed") +
theme(axis.text.x=element_text(colour="black", size = 12), axis.text.y=element_text(colour="black", size = 12)) +
theme(axis.title=element_text(size=14, colour="black", face="bold"), legend.text=element_text(size=14), legend.title=element_text(size=14)) +
scale_x_continuous(breaks=c(0, 1.81, 4.54, 7.27, 10, 12.73, 15.46, 18.19, 22),
labels = c("0\n(Min.)", "1.81\n(μ-2SD)", "4.54\n(μ-1SD)", "7.27\n(μ)", "10\n(μ+1SD)", "12.73\n(μ+2SD)","15.46\n(μ+3SD)", "18.19\n(μ+4SD)",  "22\n(Max.)")) + scale_y_continuous(breaks=number_ticks(10)) +
scale_y_continuous(labels = function(x) paste0(x * 100, '%'), limits = c(0.50, 0.90), breaks = seq(0.50, 0.90, by = 0.1)) +
labs(    x = "\n Sleep Duration (in Hours)\n",
y = "\n Fitted Values of Turnout \n",
title = "")
south_korea_plot
south_korea_plot <- ggExtra::ggMarginal(south_korea_plot, type = "boxplot")
south_korea_plot
issp_2007$predicted_netherlands <- predict(poly.issp.m1,
newdata=transform(issp_2007,
urban_rural_area_beta = 0,
age_beta  = 0,
degree_beta  = 0,
income_beta   = 0,
sex_beta   = 0,
political_interest_beta   = 0,
religiosity_beta = 0,
country="the Netherlands",
local_election=0,
mid_field_season=0,
day_off=0), type = "response", allow.new.levels=T)
netherlands <- subset(issp_2007, subset = country == "the Netherlands", select = c("sleep_duration", "predicted_netherlands"))
describe(netherlands$predicted_netherlands)
table(netherlands$predicted_netherlands)
describe(netherlands$sleep_duration)
netherlands_plot <- ggplot(netherlands, aes(x=sleep_duration, y=predicted_netherlands)) +
geom_point()  +
stat_smooth(method='lm', formula = y ~ x, size = 0.5, level = 0.95, fullrange = TRUE, color = "black", linetype="longdash") +
stat_smooth(method='lm', formula = y ~ poly(x,2), size = 0.5, level = 0.95, fullrange = TRUE, color = "black") +
theme_classic() + ggpubr::grids(linetype = "dashed") +
theme(axis.text.x=element_text(colour="black", size = 12), axis.text.y=element_text(colour="black", size = 12)) +
theme(axis.title=element_text(size=14, colour="black", face="bold"), legend.text=element_text(size=14), legend.title=element_text(size=14)) +
scale_x_continuous(breaks=c(1, 3.79, 6.19, 8.59, 10.99, 13.39, 15.79, 18.19, 22.5),
labels = c("1\n(Min.)", "3.79\n(μ-2SD)", "6.19\n(μ-1SD)", "8.59\n(μ)", "10.99\n(μ+1SD)", "13.39\n(μ+2SD)","15.79\n(μ+3SD)", "18.19\n(μ+4SD)",  "22.5\n(Max.)")) + scale_y_continuous(breaks=number_ticks(10)) +
scale_y_continuous(labels = function(x) paste0(x * 100, '%'), limits = c(0.84, 0.92), breaks = seq(0.84, 0.92, by = 0.02)) +
labs(    x = "\n Sleep Duration (in Hours)\n",
y = "\n Fitted Values of Turnout \n",
title = "")
netherlands_plot <- ggplot(netherlands, aes(x=sleep_duration, y=predicted_netherlands)) +
geom_point()  +
stat_smooth(method='lm', formula = y ~ x, size = 0.5, level = 0.95, fullrange = TRUE, color = "black", linetype="longdash") +
stat_smooth(method='lm', formula = y ~ poly(x,2), size = 0.5, level = 0.95, fullrange = TRUE, color = "black") +
theme_classic() + ggpubr::grids(linetype = "dashed") +
theme(axis.text.x=element_text(colour="black", size = 12), axis.text.y=element_text(colour="black", size = 12)) +
theme(axis.title=element_text(size=14, colour="black", face="bold"), legend.text=element_text(size=14), legend.title=element_text(size=14)) +
scale_x_continuous(breaks=c(1, 3.79, 6.19, 8.59, 10.99, 13.39, 15.79, 18.19, 22.5),
labels = c("1\n(Min.)", "3.79\n(μ-2SD)", "6.19\n(μ-1SD)", "8.59\n(μ)", "10.99\n(μ+1SD)", "13.39\n(μ+2SD)","15.79\n(μ+3SD)", "18.19\n(μ+4SD)",  "22.5\n(Max.)")) + scale_y_continuous(breaks=number_ticks(10)) +
labs(    x = "\n Sleep Duration (in Hours)\n",
y = "\n Fitted Values of Turnout \n",
title = "")
netherlands_plot
netherlands_plot <- ggplot(netherlands, aes(x=sleep_duration, y=predicted_netherlands)) +
geom_point()  +
stat_smooth(method='lm', formula = y ~ x, size = 0.5, level = 0.95, fullrange = TRUE, color = "black", linetype="longdash") +
stat_smooth(method='lm', formula = y ~ poly(x,2), size = 0.5, level = 0.95, fullrange = TRUE, color = "black") +
theme_classic() + ggpubr::grids(linetype = "dashed") +
theme(axis.text.x=element_text(colour="black", size = 12), axis.text.y=element_text(colour="black", size = 12)) +
theme(axis.title=element_text(size=14, colour="black", face="bold"), legend.text=element_text(size=14), legend.title=element_text(size=14)) +
scale_x_continuous(breaks=c(1, 3.79, 6.19, 8.59, 10.99, 13.39, 15.79, 18.19, 22.5),
labels = c("1\n(Min.)", "3.79\n(μ-2SD)", "6.19\n(μ-1SD)", "8.59\n(μ)", "10.99\n(μ+1SD)", "13.39\n(μ+2SD)","15.79\n(μ+3SD)", "18.19\n(μ+4SD)",  "22.5\n(Max.)")) + scale_y_continuous(breaks=number_ticks(10)) +
scale_y_continuous(labels = function(x) paste0(x * 100, '%'), limits = c(0.88, 0.92), breaks = seq(0.88, 0.92, by = 0.02)) +
labs(    x = "\n Sleep Duration (in Hours)\n",
y = "\n Fitted Values of Turnout \n",
title = "")
netherlands_plot
netherlands_plot <- ggplot(netherlands, aes(x=sleep_duration, y=predicted_netherlands)) +
geom_point()  +
stat_smooth(method='lm', formula = y ~ x, size = 0.5, level = 0.95, fullrange = TRUE, color = "black", linetype="longdash") +
stat_smooth(method='lm', formula = y ~ poly(x,2), size = 0.5, level = 0.95, fullrange = TRUE, color = "black") +
theme_classic() + ggpubr::grids(linetype = "dashed") +
theme(axis.text.x=element_text(colour="black", size = 12), axis.text.y=element_text(colour="black", size = 12)) +
theme(axis.title=element_text(size=14, colour="black", face="bold"), legend.text=element_text(size=14), legend.title=element_text(size=14)) +
scale_x_continuous(breaks=c(1, 3.79, 6.19, 8.59, 10.99, 13.39, 15.79, 18.19, 22.5),
labels = c("1\n(Min.)", "3.79\n(μ-2SD)", "6.19\n(μ-1SD)", "8.59\n(μ)", "10.99\n(μ+1SD)", "13.39\n(μ+2SD)","15.79\n(μ+3SD)", "18.19\n(μ+4SD)",  "22.5\n(Max.)")) + scale_y_continuous(breaks=number_ticks(10)) +
scale_y_continuous(labels = function(x) paste0(x * 100, '%'), limits = c(0.88, 0.92), breaks = seq(0.88, 0.92, by = 0.005)) +
labs(    x = "\n Sleep Duration (in Hours)\n",
y = "\n Fitted Values of Turnout \n",
title = "")
netherlands_plot
netherlands_plot <- ggplot(netherlands, aes(x=sleep_duration, y=predicted_netherlands)) +
geom_point()  +
stat_smooth(method='lm', formula = y ~ x, size = 0.5, level = 0.95, fullrange = TRUE, color = "black", linetype="longdash") +
stat_smooth(method='lm', formula = y ~ poly(x,2), size = 0.5, level = 0.95, fullrange = TRUE, color = "black") +
theme_classic() + ggpubr::grids(linetype = "dashed") +
theme(axis.text.x=element_text(colour="black", size = 12), axis.text.y=element_text(colour="black", size = 12)) +
theme(axis.title=element_text(size=14, colour="black", face="bold"), legend.text=element_text(size=14), legend.title=element_text(size=14)) +
scale_x_continuous(breaks=c(1, 3.79, 6.19, 8.59, 10.99, 13.39, 15.79, 18.19, 22.5),
labels = c("1\n(Min.)", "3.79\n(μ-2SD)", "6.19\n(μ-1SD)", "8.59\n(μ)", "10.99\n(μ+1SD)", "13.39\n(μ+2SD)","15.79\n(μ+3SD)", "18.19\n(μ+4SD)",  "22.5\n(Max.)")) + scale_y_continuous(breaks=number_ticks(10)) +
scale_y_continuous(labels = function(x) paste0(x * 100, '%'), limits = c(0.88, 0.92), breaks = seq(0.88, 0.915, by = 0.005)) +
labs(    x = "\n Sleep Duration (in Hours)\n",
y = "\n Fitted Values of Turnout \n",
title = "")
netherlands_plot
netherlands_plot <- ggplot(netherlands, aes(x=sleep_duration, y=predicted_netherlands)) +
geom_point()  +
stat_smooth(method='lm', formula = y ~ x, size = 0.5, level = 0.95, fullrange = TRUE, color = "black", linetype="longdash") +
stat_smooth(method='lm', formula = y ~ poly(x,2), size = 0.5, level = 0.95, fullrange = TRUE, color = "black") +
theme_classic() + ggpubr::grids(linetype = "dashed") +
theme(axis.text.x=element_text(colour="black", size = 12), axis.text.y=element_text(colour="black", size = 12)) +
theme(axis.title=element_text(size=14, colour="black", face="bold"), legend.text=element_text(size=14), legend.title=element_text(size=14)) +
scale_x_continuous(breaks=c(1, 3.79, 6.19, 8.59, 10.99, 13.39, 15.79, 18.19, 22.5),
labels = c("1\n(Min.)", "3.79\n(μ-2SD)", "6.19\n(μ-1SD)", "8.59\n(μ)", "10.99\n(μ+1SD)", "13.39\n(μ+2SD)","15.79\n(μ+3SD)", "18.19\n(μ+4SD)",  "22.5\n(Max.)")) + scale_y_continuous(breaks=number_ticks(10)) +
scale_y_continuous(labels = function(x) paste0(x * 100, '%'), limits = c(0.88, 0.92), breaks = seq(0.88, 0.92, by = 0.005)) +
labs(    x = "\n Sleep Duration (in Hours)\n",
y = "\n Fitted Values of Turnout \n",
title = "")
netherlands_plot
netherlands_plot <- ggExtra::ggMarginal(netherlands_plot, type = "boxplot")
netherlands_plot
issp_2007$predicted_russia <- predict(poly.issp.m1,
newdata=transform(issp_2007,
urban_rural_area_beta = 0,
age_beta  = 0,
degree_beta  = 0,
income_beta   = 0,
sex_beta   = 0,
political_interest_beta   = 0,
religiosity_beta = 0,
country="Russia",
local_election=0,
mid_field_season=0,
day_off=0), type = "response", allow.new.levels=T)
russia <- subset(issp_2007, subset = country == "Russia", select = c("sleep_duration", "predicted_russia"))
describe(russia$predicted_russia)
table(russia$predicted_russia)
describe(russia$sleep_duration)
russia_plot <- ggplot(russia, aes(x=sleep_duration, y=predicted_russia)) +
geom_point()  +
stat_smooth(method='lm', formula = y ~ x, size = 0.5, level = 0.95, fullrange = TRUE, color = "black", linetype="longdash") +
stat_smooth(method='lm', formula = y ~ poly(x,2), size = 0.5, level = 0.95, fullrange = TRUE, color = "black") +
theme_classic() + ggpubr::grids(linetype = "dashed") +
theme(axis.text.x=element_text(colour="black", size = 12), axis.text.y=element_text(colour="black", size = 12)) +
theme(axis.title=element_text(size=14, colour="black", face="bold"), legend.text=element_text(size=14), legend.title=element_text(size=14)) +
scale_x_continuous(breaks=c(0, 1.23, 5, 8.77, 12.54, 16.31, 20.08, 23.5),
labels = c("0\n(Min.)", "1.23\n(μ-2SD)", "5\n(μ-1SD)", "8.77\n(μ)", "12.54\n(μ+1SD)", "16.31\n(μ+2SD)", "20.08\n(μ+3SD)",  "23.5\n(Max.)")) + scale_y_continuous(breaks=number_ticks(10)) +
labs(    x = "\n Sleep Duration (in Hours)\n",
y = "\n Fitted Values of Turnout \n",
title = "")
russia_plot
russia_plot <- ggplot(russia, aes(x=sleep_duration, y=predicted_russia)) +
geom_point()  +
stat_smooth(method='lm', formula = y ~ x, size = 0.5, level = 0.95, fullrange = TRUE, color = "black", linetype="longdash") +
stat_smooth(method='lm', formula = y ~ poly(x,2), size = 0.5, level = 0.95, fullrange = TRUE, color = "black") +
theme_classic() + ggpubr::grids(linetype = "dashed") +
theme(axis.text.x=element_text(colour="black", size = 12), axis.text.y=element_text(colour="black", size = 12)) +
theme(axis.title=element_text(size=14, colour="black", face="bold"), legend.text=element_text(size=14), legend.title=element_text(size=14)) +
scale_x_continuous(breaks=c(0, 1.23, 5, 8.77, 12.54, 16.31, 20.08, 23.5),
labels = c("0\n(Min.)", "1.23\n(μ-2SD)", "5\n(μ-1SD)", "8.77\n(μ)", "12.54\n(μ+1SD)", "16.31\n(μ+2SD)", "20.08\n(μ+3SD)",  "23.5\n(Max.)")) + scale_y_continuous(breaks=number_ticks(10)) +
scale_y_continuous(labels = function(x) paste0(x * 100, '%'), limits = c(0.955, 1), breaks = seq(0.955, 1, by = 0.005)) +
labs(    x = "\n Sleep Duration (in Hours)\n",
y = "\n Fitted Values of Turnout \n",
title = "")
russia_plot
russia_plot <- ggExtra::ggMarginal(russia_plot, type = "boxplot")
russia_plot
poly_figures <- ggpubr::ggarrange(finland_plot,  greece_plot,
ireland_plot, mexico_plot, netherlands_plot, new_zealand_plot,
philippines_plot, russia_plot, south_korea_plot,
ncol=3, nrow = 3, labels = c("A: Finland", "B: Greece",
"C: Ireland", "D: Mexico",
"E: the Netherlands",
"F: New Zealand",
"G: the Philippines", "H: Russia", "I: South Korea"))
poly_figures
ggsave(filename = "poly_figures_with_excluded_19.jpg",plot = poly_figures, width = 28, height = 16, dpi = 1000)
